import React from 'react'

const Logn = () => {
  // 存储用户名和密码
  const [username,setUsername]=React.useState('')
  const [password,setPassword]=React.useState('')
  // 登录
  const login=()=>{
    console.log(username,password)
    // 存入本地存储


    if(username==='张三'&&password==='123456'){
      alert('登录成功')
          localStorage.setItem('username',username)
    localStorage.setItem('password',password)
      window.location.href='/Home'
    }else{
      alert('登录失败')
    }
  }
 
  return (
    <div>
      {/* 登录 */}
     <p> <input type="text" placeholder='请输入用户名' onChange={(e)=>setUsername(e.target.value)}  /></p>
    <p> <input type="text" placeholder='请输入密码' onChange={(e)=>setPassword(e.target.value)} /></p>
      <button onClick={()=>login()}>登录</button>
    </div>
  )
}

export default Logn